﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace TractRecord.Process
{
    public partial class PasswordRecovery : TractRecordBasePage 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            PasswordRecoveryControl.VerifyingUser += new LoginCancelEventHandler(PasswordRecoveryControl_VerifyingUser);
        }

        void PasswordRecoveryControl_VerifyingUser(object sender, LoginCancelEventArgs e)
        {
            if (Membership.FindUsersByName(PasswordRecoveryControl.UserName).Count <= 0)
            {
                MembershipUserCollection users = Membership.FindUsersByEmail(PasswordRecoveryControl.UserName);

                if (users.Count > 0)
                {
                    foreach (MembershipUser user in users)
                    {
                        PasswordRecoveryControl.UserName = user.UserName;
                        break;
                    }

                }
            }
        }
    }
}